// SGJ Apps Bible Input Method (BibleIM).  A collection
// of Java InputMethods enabling the easy typing of Biblical scripts.
// Copyright (C) 2007-2008 Steffen G. Jenkins  

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

/*
 * SingleKeyPanel.java
 *
 * Created on 06 September 2007, 20:24
 */

package uk.org.sgj.BibleIM;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

/**
 *
 * @author  Steffen
 */
public class SingleKeyPanel extends javax.swing.JPanel
{
    protected static final int stdHeight = 50;
    protected static final int stdWidth = 35;
    
    protected void setFontForKeys(Font f)
    {
        normalKeyArea.setFont(f);
        originalKeyArea.setFont(f);
        shiftKeyArea.setFont(f);
    }
    
    public SingleKeyPanel(char originalChar, char lowerChar, char upperChar)
    {
        initComponents();
        setPreferredSize(new Dimension(stdWidth, stdHeight));
        setMinimumSize(new Dimension(stdWidth, stdHeight));
        
        int charType = Character.getType(upperChar);
        String upperString;

        if (((charType == Character.COMBINING_SPACING_MARK) || (charType == Character.NON_SPACING_MARK)) &&
            ((upperChar < '\u0500') || (upperChar > '\u0600'))                                             )
        {
            upperString = "\u25CC"+upperChar;
            shiftKeyArea.setForeground(new Color(102,0,102));
        }
        else
        {
            upperString = Character.toString(upperChar);
        }
        
        shiftKeyArea.setText(upperString);
        originalKeyArea.setText(""+originalChar);
        normalKeyArea.setText(""+lowerChar);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents()
    {
        topLeft = new javax.swing.JTextArea();
        shiftKeyArea = new javax.swing.JTextArea();
        originalKeyArea = new javax.swing.JTextArea();
        normalKeyArea = new javax.swing.JTextArea();

        setLayout(new java.awt.GridLayout(2, 2));

        setBorder(javax.swing.BorderFactory.createEtchedBorder());
        topLeft.setColumns(1);
        topLeft.setEditable(false);
        topLeft.setFont(new java.awt.Font("Serif", 0, 18));
        topLeft.setRows(1);
        topLeft.setAutoscrolls(false);
        topLeft.setMargin(new java.awt.Insets(0, 0, 0, 0));
        topLeft.setMinimumSize(new java.awt.Dimension(20, 30));
        topLeft.setVerifyInputWhenFocusTarget(false);
        add(topLeft);

        shiftKeyArea.setColumns(1);
        shiftKeyArea.setEditable(false);
        shiftKeyArea.setFont(new java.awt.Font("Serif", 0, 18));
        shiftKeyArea.setForeground(new java.awt.Color(153, 0, 51));
        shiftKeyArea.setRows(1);
        shiftKeyArea.setAutoscrolls(false);
        shiftKeyArea.setMargin(new java.awt.Insets(0, 0, 0, 0));
        shiftKeyArea.setMinimumSize(new java.awt.Dimension(20, 30));
        shiftKeyArea.setVerifyInputWhenFocusTarget(false);
        add(shiftKeyArea);

        originalKeyArea.setColumns(1);
        originalKeyArea.setEditable(false);
        originalKeyArea.setFont(new java.awt.Font("Serif", 0, 18));
        originalKeyArea.setForeground(new java.awt.Color(0, 51, 255));
        originalKeyArea.setRows(1);
        originalKeyArea.setAutoscrolls(false);
        originalKeyArea.setMargin(new java.awt.Insets(0, 0, 0, 0));
        originalKeyArea.setMinimumSize(new java.awt.Dimension(20, 30));
        originalKeyArea.setVerifyInputWhenFocusTarget(false);
        add(originalKeyArea);

        normalKeyArea.setColumns(1);
        normalKeyArea.setEditable(false);
        normalKeyArea.setFont(new java.awt.Font("Serif", 0, 18));
        normalKeyArea.setRows(1);
        normalKeyArea.setAutoscrolls(false);
        normalKeyArea.setMargin(new java.awt.Insets(0, 0, 0, 0));
        normalKeyArea.setMinimumSize(new java.awt.Dimension(20, 30));
        normalKeyArea.setVerifyInputWhenFocusTarget(false);
        add(normalKeyArea);

    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea normalKeyArea;
    private javax.swing.JTextArea originalKeyArea;
    private javax.swing.JTextArea shiftKeyArea;
    private javax.swing.JTextArea topLeft;
    // End of variables declaration//GEN-END:variables
    
}
